<?php

namespace app\api\model;

use common\model\base\BaseModel;
use common\traits\InstanceTrait;

/**
 * Class AdminRight
 * @package app\api\model
 */
class AdminRight extends BaseModel
{
    use InstanceTrait;

    protected $pk = 'right_id';

    public function getRight($module, $controller, $action)
    {
        //寻找允许$module, $controller, $action的权限id
        $where = [
            ['module', ['=', $module], ['=', '*'], 'or'],
            ['controller', ['=', $controller], ['=', '*'], 'or'],
            ['action', ['=', $action], ['=', '*'], 'or'],
        ];
        return static::where($where)->field('right_id')->select();

    }

}
